﻿using System;
using System.Web;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.Default.model;
using System.Web.Security;
using System.Data.SqlClient;

namespace Jxym.wlkc2011.Module.Default.SERVER.module
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string returnValue = "{'success':false,'msg':'用户验证失败'}";

                string account = "0"; if (Request.Params["account"] != null) { account = Request.Params["account"]; }
                string password = "0"; if (Request.Params["password"] != null) { password = Request.Params["password"]; }
                string ispersistent = "false"; if (Request.Params["ispersistent"] != null) { ispersistent = Request.Params["ispersistent"]; }

                if (account != "0" && password != "0")
                {
                    MsSqlDal<User_Info> iUi = new MsSqlDal<User_Info>();

                    SqlParameter[] parameters = new SqlParameter[]{
                        new SqlParameter("@Account",account),
                        new SqlParameter("@Password",password)
                    };

                    User_Info ui = iUi.GetModel("Account=@Account AND Password=@Password", parameters);

                    if (ui != null)
                    {
                        Jxym.Common.Request.SetAdminID(ui.ID.ToString(), 30, (ispersistent != "true" ? false : true), "user");
                        returnValue = "{'success':true}";
                    }
                }
                Response.Write(returnValue);

            }
        }
    }
}